home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1 / Ian and Stuart's One (Australia).iso / Australasian Legends / Commercial / Rainbow Hill / MacDOS™ 2.0.0 / User's Guide / 13.2 DIR - INCR < prev    next >
Text File  |  1994-09-20  |  32KB  |  767 lines

  1. DIR
  2.        lists the contents of a folder (ie. a DIRectory).
  3.  
  4.    Syntax
  5.        dir [selection] [/[-]A[[:]attribute list]] [/[-]B]
  6.        [/C=creator] [/[-]L] [/[-]O[[:]ordering list]] [/[-]P] [/[-
  7.        ]S] [/T=file type] [/[-]W]
  8.  
  9.    Parameters
  10.        selection
  11.        is  a  name  preceded by an absolute or relative path  which
  12.        specifies  the  items  to be listed. A  group  of  files  is
  13.        identified  via a wildcarded filename or a folder  name.  If
  14.        selection is omitted, DIR lists the contents of the  current
  15.        folder.
  16.  
  17.    Switches
  18.        /[-]A[[:]attribute list]
  19.        only   lists   items  with  attributes   included   in   the
  20.        attribute  list  (but  look at the note concerning  DIRCMD).
  21.        The attribute list is a string of single letter attributes:
  22.           D  for Directories,
  23.           F  for visible Files,
  24.           H  for Hidden files,
  25.           X  for aliases.
  26.        A  minus  sign  preceding an attribute tells MacDOS  not  to
  27.        list  items with that attribute. A minus sign between the  /
  28.        and  the  A  inverts  the  logic of all  attributes  in  the
  29.        attribute  list.  By default, MacDOS does  not  list  hidden
  30.        files.
  31.  
  32.        /B
  33.        lists  item  names one per line and without  headings  (bare
  34.        format).  When the /S option is also ON, /B writes the  full
  35.        path  instead  of the item name only. A minus  sign  between
  36.        the / and the B switches this option OFF.
  37.  
  38.        /C=creator
  39.        specifies that only files of a particular creator are to  be
  40.        listed.  Note that no spaces are allowed on either  side  of
  41.        the   equal  sign  and  that  the  creator  string  is  four
  42.        characters  long.  Therefore, if a creator includes  spaces,
  43.        you  must double quote the switch (eg. dir \ "/c=ABC " lists
  44.        all the files created by 'ABC ' in the root folder).
  45.  
  46.        /L
  47.        operates case-sensitive matching on the selection.  A  minus
  48.        sign between the / and the L switches this option OFF.
  49.  
  50.        [/[-]O[[:]ordering list]]
  51.        sorts  the  items as specified in the ordering  list  before
  52.        listing  them.  The  ordering list is  a  string  of  single
  53.        letter sorting criteria:
  54.           D  by Date & time of update (older first)
  55.           G  Group directories first
  56.           N  by Name (alphabetic)
  57.           S  by Size (smallest first)
  58.        A  minus sign preceding a sorting criterion tells MacDOS  to
  59.        sort  in the reverse order. A minus sign between the  /  and
  60.        the   O   inverts   the  logic  of  all  criteria   in   the
  61.        ordering list.
  62.  
  63.        /P
  64.        pauses  after  each  screenful  of  listing.  A  minus  sign
  65.        between the / and the P switches this option OFF.
  66.  
  67.        /S
  68.        provides   a   recursive  display  of  the  items   in   all
  69.        subfolders.  A minus sign between the / and the  S  switches
  70.        this option OFF.
  71.  
  72.        /T=file type
  73.        specifies  that only files of a particular type  (eg.  TEXT)
  74.        are  to be listed. Note that no spaces are allowed on either
  75.        side  of  the  equal  sign and that the file  type  is  four
  76.        characters long. Therefore, if a file type includes  spaces,
  77.        you  must double quote the switch (eg. dir \ "/t=ABC " lists
  78.        all the files of type 'ABC ' in the root folder).
  79.  
  80.        /W
  81.        lists  item names in a wide format, with as many  items  per
  82.        line  as  possible. A minus sign between the  /  and  the  W
  83.        switches this option OFF.
  84.  
  85.    MacDOS vs DOS
  86.        Switches
  87.        The  switches  /AS, /AA, /AR, and /OE are  not  implemented,
  88.        but /AF, /AX, /C, and /T have been introduced.
  89.  
  90.        Directory header
  91.        To  cope with the long names typical of the Mac, the path in
  92.        the  directory  header is displayed with one directory  name
  93.        per line.
  94.  
  95.        Names containing spaces
  96.        All   names  displayed  are  quoted,  so  that  leading  and
  97.        trailing  spaces  are made visible. Use the system  variable
  98.        QUOTE to change the quoting character.
  99.  
  100.        Creators and File Types
  101.        Creator and file-type are displayed.
  102.  
  103.        Listing of aliases
  104.        Target  volume  and  target filename of  aliased  items  are
  105.        displayed  immediately  after the directory  entry  for  the
  106.        alias file itself.
  107.  
  108.        Date and time formats
  109.        Date  and  time  are displayed in the format chosen  by  you
  110.        (refer to the two commands DATE and TIME).
  111.  
  112.    Notes
  113.        DIRCMD
  114.        Before  executing  the  command  DIR,  MacDOS  selects   the
  115.        switches   contained   in   the  system   variable   DIRCMD.
  116.        Therefore,  DIRCMD  represents the system default  switches.
  117.        You  can  override  the  defaults  by  explicitly  including
  118.        switches  in  the command (/-B negates /B, /W  negates  /-W,
  119.        etc.).  Alternatively,  you  can  SET  DIRCMD  to  your  own
  120.        preferred  defaults. For instance, you can  include  /AH  so
  121.        that hidden files are always displayed. By including such  a
  122.        SET  command in the autoexec.bat file, you only need to type
  123.        your preferred defaults once. The system defaults are:
  124.         /-P     do not pause at the end of each page
  125.         /-W     do not list in wide format
  126.          /A:-HDXF   list directories, aliases, and files,  but  not
  127.        hidden files
  128.         /-O     do not sort
  129.         /-S     list only the current folder (not recursively)
  130.         /-B     do not list in bare format
  131.         /-L     operate case-insensitive
  132.  
  133.        Repetition of switches in the same command
  134.        Switches can be repeated. As MacDOS scans the switches  from
  135.        left  to  right,  the rightmost switch of a particular  type
  136.        overrides  the preceding ones. /A and /O can be repeated  to
  137.        extend  their  sub-option  lists.  For  example,  /A-H-D  is
  138.        totally equivalent to /A-H/A-D.
  139.  
  140.        Conflicting attributes in the attribute list
  141.        MacDOS  scans the attributes of the /A switch from  left  to
  142.        right.  Therefore, the rightmost attribute of  a  particular
  143.        type  takes  effect. For example, /A:HDF-H does not  display
  144.        hidden  files. If you type /-ADFH (or an equivalent sequence
  145.        of  attributes) you never get any item listed,  because  you
  146.        exclude  both  folders  and files  (aliases  are  particular
  147.        cases of files).
  148.  
  149.        Complex sorting
  150.        MacDOS   scans  the  ordering  list  from  left  to   right.
  151.        Therefore, the rightmost sorting is done last. For  example,
  152.        /O:SN  first  sorts  by size, and then by  name.  Note  that
  153.        names  are  unique.  Therefore, if you  sort  by  name,  all
  154.        preceding   sorts  become  totally  irrelevant.  A   similar
  155.        consideration  also  applies to /O:D, because  the  time  of
  156.        update  is  also  almost  always unique.  The  situation  is
  157.        different when you apply /ON or /OD before applying  /OG  or
  158.        /OS.  For  example,  if  you  apply  /O:NSG,  you  list  the
  159.        directories  ordered by name followed by the  files  ordered
  160.        by  size, with files of the same size in alphabetical  order
  161.        of their names.
  162.  
  163.        Sorting and recursion
  164.        Each folder is sorted individually.
  165.  
  166.        Aliases
  167.        Under normal circumstances, DIR displays two lines for  each
  168.        alias.  The  first  line refers to the  alias  file  itself,
  169.        while  the  second line refers to the target. If  the  alias
  170.        cannot  be  resolved (perhaps because the  target  is  on  a
  171.        volume  which has not been mounted), DIR reports  a  warning
  172.        and  then  only  displays the first line with an  indication
  173.        that the file is an alias.
  174.  
  175.        Note  that  when listing an alias, MacDOS always  lists  the
  176.        corresponding   targets,  regardless  of  their   type   and
  177.        visibility.
  178.  
  179.        Memory limitations
  180.        DIR   saves  folder  information  in  dynamically  allocated
  181.        memory  rather than on disk. This speeds up the listing  but
  182.        limits  the  number  of  directory items  which  MacDOS  can
  183.        handle. With the current memory partition, this limit is  of
  184.        approximately  1100  entries. If MacDOS  returns  the  error
  185.        "Not enough space in the heap", the only solution (short  of
  186.        splitting  the  folder  which is  causing  problems)  is  to
  187.        increase  the  amount of memory allocated to MacDOS.  To  do
  188.        so,  exit MacDOS, click once on the application icon,  press
  189.        cmd-I, and increment the partition size.
  190.  
  191.    Examples
  192.        dir                lists   the   contents  of  the   current
  193.                            folder.
  194.        dir 2:/p           lists   the   contents  of  the   current
  195.                            folder  of  volume 2 and pauses  at  the
  196.                            end of each page.
  197.        dir abc            lists  the  file abc or the  contents  of
  198.                            the  folder abc contained in the current
  199.                            folder
  200.        dir ..\abc*        lists   all  the  items  of  the   parent
  201.                            folder whose name begins with abc.
  202.        dir \/w            lists  the  contents of the  root  folder
  203.                            in a wide format.
  204.        dir/t=TEXT/s       recursively lists all text files  in  the
  205.                            current folder and in its subfolders
  206.        dir \a\b\*TEMP*/L  lists  all  the files in the folder  \a\b
  207.                            whose  name  contains  the  string  TEMP
  208.                            (case sensitive).
  209.        dir/o-s/a-d        lists  the  files  (not the  folders)  in
  210.                            the  current  folder in  order  of  size
  211.                            (from the largest to the smallest).
  212.        dir \/s/b/c=ABCD/a-d    lists  all the files on the  current
  213.                            volume  created by ABCD. For each  item,
  214.                            the full path and name is given.
  215.        dir \t*/s/b/a-f    lists   all  the  folder  names  in   the
  216.                            current volume which start with  't'  or
  217.                            'T'.
  218.        dir/a-d-x/s/b>aFile \   saves  into a file named  aFile  the
  219.                            list  of  all  non-alias  files  in  the
  220.                            current volume. For each item, the  full
  221.                            path and name is given.
  222.        dir /o-d/c=MWII    lists   all  MacWrite  II  documents   in
  223.                            order of update, from the newest to  the
  224.                            oldest.
  225.        dir 1:\/s/b/a-d-fh lists  all  hidden files on  the  startup
  226.                            volume.  For  each item, the  full  path
  227.                            and name is given.
  228.  
  229.    Frequently occurring errors
  230.        E27: File or directory not found
  231.        Perhaps  you specified a proper filename (without wildcards)
  232.        but  the  file does not exist. Alternatively, it is  one  of
  233.        the folders within the path which does not exist.
  234.  
  235.    See Also
  236.        TREE
  237.  
  238.  
  239. ECHO
  240.        displays  messages  or turns batch command  echoing  ON  and
  241.        OFF.
  242.  
  243.    Syntax
  244.        echo [{message | ON | OFF}]
  245.        echo.
  246.  
  247.    Parameters
  248.        {message | ON | OFF}
  249.        is  a  string to be displayed in the MacDOS window.  If  the
  250.        string  only consists of the word ON, ECHO does not  display
  251.        it  but  enables  the  echoing of  commands  to  the  MacDOS
  252.        window.  Similarly, OFF causes the echoing to  be  disabled.
  253.        If  the  parameter  is entirely missing, ECHO  displays  the
  254.        current echo setting (ON or OFF).
  255.  
  256.        ECHO  immediately followed by a period (a dot) just displays
  257.        an empty line.
  258.  
  259.    MacDOS vs DOS
  260.        The two implementations are identical.
  261.  
  262.    Notes
  263.        Interactive usage
  264.        MacDOS  lets you use ECHO interactively. Therefore,  if  you
  265.        want  to  view  a  single global variable, type  ECHO  %var%
  266.        rather than SET .
  267.  
  268.        Output redirection
  269.        ECHO  redirects its output when you include it  in  a  batch
  270.        program and redirect the output of the whole batch.
  271.  
  272.  
  273. EJECT
  274.        dismounts and places off-line removable volumes.
  275.  
  276.    Syntax
  277.        eject volume [/E]
  278.  
  279.    Parameters
  280.        volume
  281.        is  the  ID which identifies the volume to be dismounted  or
  282.        placed  off-line.  Without  switches,  EJECT  dismounts  the
  283.        volume.
  284.  
  285.    Switches
  286.        /E
  287.        specifies  that  the  volume is only to be  placed  off-line
  288.        (eg. Ejected) without being dismounted.
  289.  
  290.    MacDOS vs DOS
  291.        DOS does not support EJECT.
  292.  
  293.    Notes
  294.        The  start-up  volume  cannot be  dismounted  regardless  of
  295.        whether it is removable or not.
  296.  
  297.    Examples
  298.        eject 2:
  299.        removes  the volume with ID 2. The icon disappears from  the
  300.        desktop.
  301.  
  302.        eject D /e
  303.        ejects the volume D. The icon is then greyed.
  304.  
  305.  
  306. EXIT
  307.        quits MacDOS, other applications, or the Finder.
  308.  
  309.    Syntax
  310.        exit [appl]
  311.        exit finder
  312.  
  313.    Parameters
  314.        appl
  315.        identifies the application that should receive a Quit  Apple
  316.        Event.  If  the  parameter  is  missing,  MacDOS  terminates
  317.        itself.
  318.  
  319.    MacDOS vs DOS
  320.        In  DOS, EXIT is used to quit the current shell and possibly
  321.        return to a program which was suspended.
  322.  
  323.    Notes
  324.        EXIT's  main purpose is to use batch programs as stand-alone
  325.        applications which automatically terminate after  completing
  326.        their task.
  327.  
  328.        Quitting the Finder
  329.        When  you kill the Finder, you no longer have access to  the
  330.        items  normally  in  the Apple menu. Be warned  that  MacDOS
  331.        relies  on  the  'MACS'  creator  to  identify  the  process
  332.        associated  with  the Finder. If you have  already  replaced
  333.        the  Finder with a different application, the "exit  finder"
  334.        command will have no effect.
  335.  
  336.        You can re-launch the Finder by typing its path/filename  as
  337.        if  it  were  a  normal application. Make an  alias  of  the
  338.        Finder, name it F, and place it in a folder included in  the
  339.        search  PATH.  You will then be able to then  re-launch  the
  340.        Finder with just two key strokes.
  341.  
  342.  
  343. FOR
  344.        executes a command or a series of commands for each file  in
  345.        a set.
  346.  
  347.    Syntax
  348.        for %var [/L] in (set) do [command | begin]
  349.  
  350.    Parameters
  351.        var
  352.        is  the  name  of the variable that FOR uses  to  store  the
  353.        names  of the files in set, one at a time. When you use  the
  354.        format  "do command", type the string %var where  you  would
  355.        normally type a filename. FOR then executes the command  for
  356.        all  files  in  the  set, one at a time. When  you  use  the
  357.        format  "do  begin",  var becomes a global  variable  rather
  358.        than  a  variable  local to FOR. Therefore,  type  %var%  to
  359.        obtain the name of the current file.
  360.  
  361.        set
  362.        is  a  list  of  space-separated items, where each  item  is
  363.        either  a  file or a folder name. Each item can be  preceded
  364.        by  a volume and path spec, and filenames can be wildcarded.
  365.        The parentheses are mandatory.
  366.  
  367.        command | begin
  368.        is  either  the single command to be executed or  a  keyword
  369.        which  starts  the execution of a series of  command  lines.
  370.        With  begin, MacDOS keeps executing command lines  until  it
  371.        encounters a line containing the command NEXT var . At  that
  372.        point,  MacDOS sets var to the next filename in the set  and
  373.        resumes  execution from the line immediately  following  the
  374.        begin.  After 'using' all the files in set, MacDOS continues
  375.        execution  of  the  batch program from the line  immediately
  376.        following the NEXT.
  377.  
  378.    Switches
  379.        /L
  380.        leaves  the  filenames  in  the set  as  they  are,  without
  381.        converting  them  to  uppercase. The  default  is  that  the
  382.        filenames are converted. This switch must precede the do.
  383.  
  384.    MacDOS vs DOS
  385.        Multi-line FORs
  386.        The  keyword begin allows for loops spanning over more  than
  387.        one line.
  388.  
  389.        De-referencing the loop control variable
  390.        With  standard  single-line FORs, the  control  variable  is
  391.        always  de-referenced by prepending a  single  percent  sign
  392.        (as  in  %varName), regardless of whether the FOR  is  in  a
  393.        batch  program  or not. DOS needs a double percent  sign  in
  394.        batch  programs. With multi-line loops, the control variable
  395.        becomes  a  standard  global variable and  is  de-referenced
  396.        normally (as in %varName%).
  397.  
  398.        Lower case option
  399.        DOS does not support /L.
  400.  
  401.        What can be done
  402.        Beside  normal  commands, MacDOS also accepts program  names
  403.        and the command CALL after the do.
  404.  
  405.        Folder expansion
  406.        Folder names in a set are expanded, so that (folderName)  in
  407.        MacDOS is equivalent to (folderName\*.*) in DOS. This  seems
  408.        more  consistent  with  the way in which  folder  names  are
  409.        usually handled by file-oriented commands.
  410.  
  411.    Notes
  412.        Replacing FOR
  413.        FOR  is a command which has mainly been implemented to  help
  414.        experienced  DOS users. Although it has been extended  in  a
  415.        series of ways, its use remains limited because it does  not
  416.        distinguish between file types, does not return full  paths,
  417.        and  does not operate recursively. The most flexible way  of
  418.        operating  on  a  set of files with MacDOS  is  to  use  the
  419.        following strategy:
  420.        •  redirect  the  output  of  DIR/B  to  a  file  (all   the
  421.           filtering  options  of  DIR  as  well  as  its  recursive
  422.           operation are available);
  423.        •  OPEN the file;
  424.        •  repeat the READing of the file, so that a filename  at  a
  425.           time is stored in a global variable and is available  for
  426.           processing;
  427.        •  CLOSE  the  file  (only  if you do  not  reach  the  EOF,
  428.           otherwise MacDOS closes the file automatically);
  429.        •  reSET  the  global  variables used and  DELete  the  file
  430.           (always   clean-up  the  mess  before  you  start   doing
  431.           something else).
  432.  
  433.        Interactive vs. batch
  434.        You  can  execute the standard FOR interactively, while  you
  435.        can only use the multi-line FOR within batch programs.
  436.  
  437.        What  happens to the control variable after exiting the  FOR
  438.        loop
  439.        The  control  variable  of standard single-line  FORs  is  a
  440.        local  variable and is not accessible within other commands.
  441.        On  the other hand, the control variable of multi-line  FORs
  442.        is  a  normal global variable. After terminating  the  loop,
  443.        such  a  variable contains the name of the last file in  the
  444.        set  and  it is your responsibility to remove it by  SETting
  445.        it  to  the  empty  string. To remove it  immediately  after
  446.        exiting the loop is a good defensive practice.
  447.  
  448.        I/O redirection
  449.        Redirection  is  only  legal with the  standard  single-line
  450.        format  of  FOR.  In that case, it applies  to  the  command
  451.        which follows the do rather than to the FOR itself.
  452.  
  453.        Piping  of the output to other commands is forbidden  except
  454.        to  MORE. To put it simply, FOR only supports piping in  the
  455.        following case:
  456.          FOR  %var  [/L]  IN  (set)  DO internal-com-with-params  |
  457.           MORE
  458.  
  459.        Incompatibility of commands
  460.        Standard  FORs cannot be nested. That is, no FOR command  is
  461.        allowed  after the do keyword of another FOR. IFs  are  also
  462.        forbidden within standard FORs.
  463.  
  464.        Empty set
  465.        If  the set does not select any file, FORs do not return any
  466.        error   and  multi-line  FORs  do  not  create  the   global
  467.        variable.
  468.  
  469.        Running away
  470.        If  a command within a FOR generates a file which belongs to
  471.        the  set, a situation in which the loop "feeds" itself  with
  472.        new  files can occur. Such a "runaway" condition would  only
  473.        stop  upon hitting some system boundaries. Here are a couple
  474.        of examples:
  475.  
  476.        for %var in (d*) do dir/b > %varX
  477.          this  command  generates a file for each file  whose  name
  478.           begins  with the letter 'd'. Unfortunately, the new  file
  479.           also  begins with 'd' and is therefore part of  the  set.
  480.           To  see  what  happens, let's say that you  have  a  file
  481.           named  DATA.  In  the first iteration  of  the  FOR-loop,
  482.           MacDOS  generates DATAX; in the second iteration  DATAXX;
  483.           then  DATAXXX;  etc.  This only stops  when  the  maximum
  484.           length  of filenames (31 characters) is reached.  If  you
  485.           had  named  the  new files X%var instead  of  %varX,  you
  486.           would have been fine.
  487.  
  488.        set counter=0
  489.        for %var in (*t*) do begin
  490.           incr counter
  491.           copy %var% data%counter%
  492.        next var
  493.          here   the  purpose  was  to  make  copies  of  all  files
  494.           containing  the  letter 't' and name them  data1,  data2,
  495.           etc. Again, the problem is that the new files are in  the
  496.           set.  New files are probably created until the hard  disk
  497.           is  full. You could have named the new files xxx%counter%
  498.           and  then renamed them with  ren xxx* data*  at  a  later
  499.           stage.  Alternatively, you could have stored  the  copies
  500.           into a different folder.
  501.        The  general  solution is to replace FOR with a  combination
  502.        of  DIR  and a loop. This would avoid the risk of  "positive
  503.        feedback".
  504.  
  505.    Examples
  506.        for %a in (wildcardedFilename) do more < %a
  507.        executes    a    MORE   on   all   files    identified    by
  508.        wildcardedFilename (it only works with files in the  current
  509.        folder and if they are of type 'TEXT').
  510.  
  511.        for %a in (myDir) do more < myDir\%a
  512.        executes  a MORE on all files in the folder myDir  (it  only
  513.        works if the files are of type 'TEXT').
  514.  
  515.    Frequently occurring errors
  516.        E27: File or directory not found
  517.        At  least  one of the paths specified in the set included  a
  518.        folder which does not exist.
  519.  
  520.    See Also
  521.        NEXT
  522.  
  523.  
  524. GOTO
  525.        while in batch, continues execution from a labelled line.
  526.  
  527.    Syntax
  528.        goto label
  529.  
  530.    Parameters
  531.        label
  532.        is  an  alphanumeric string used as a label in  the  current
  533.        batch program. Remember that the colon which identifies  the
  534.        label is not part of the label itself.
  535.  
  536.    MacDOS vs DOS
  537.        The two implementations are identical.
  538.  
  539.    Examples
  540.        goto QUIT_LBL
  541.        goto 4
  542.        GOTO lbl10
  543.        goto %var%
  544.  
  545.    Frequently occurring errors
  546.        E44: Label not found
  547.        The  requested  label was not defined in the  current  batch
  548.        program.
  549.  
  550.  
  551. HELP
  552.        provides on-line information for all MacDOS commands.
  553.  
  554.    Syntax
  555.        help [entry]
  556.  
  557.    Parameters
  558.        entry
  559.        is  either  a  command  name, a  file  specification,  or  a
  560.        question mark.
  561.  
  562.        When  entry  is a command name, HELP displays a  description
  563.        of the command.
  564.  
  565.        When  entry  identifies a file, HELP searches  the  resource
  566.        fork  of  the  file looking for a resource  of  type  'TEXT'
  567.        named  "help".  If it finds it, it display its  contents  in
  568.        the  console window. This lets you get help on any  program,
  569.        filter,  and  script  provided it contains  the  appropriate
  570.        'TEXT' resource.
  571.  
  572.        When  entry  is a question mark, HELP lists all the  command
  573.        names.
  574.  
  575.        If  entry is missing, HELP lists brief descriptions  of  all
  576.        the commands.
  577.  
  578.    MacDOS vs DOS
  579.        The  two implementations are identical, except for the  fact
  580.        that  MacDOS  supports  "HELP ?" and can  read  "help"  text
  581.        resources.
  582.  
  583.  
  584. IF
  585.        performs conditional processing in batch.
  586.  
  587.    Syntax
  588.        if [not] {s1 == s1 | exist name | existdir name} command
  589.  
  590.    Parameters
  591.        {s1 == s1 | exist name | existdir name}
  592.        is a condition which can have three forms:
  593.          s1 == s1
  594.          is  true  when  the two strings s1 and s2  are  identical.
  595.           The  two  strings can contain replaceable parameters  and
  596.           global variables.
  597.          exist name
  598.          is  true  when  a  file  named  name  exists.  The  actual
  599.           filename  can  be preceded by a volume specification  and
  600.           path.
  601.          existdir name
  602.          is  true  when  a  folder named name  exists.  The  actual
  603.           folder  name  can  be preceded by a volume  specification
  604.           and path.
  605.        A  not  preceding  a condition changes a true  condition  to
  606.        false and vice versa.
  607.  
  608.        command
  609.        is  executed when the condition is true. It can be a  MacDOS
  610.        command or the name of an executable program.
  611.  
  612.    MacDOS vs DOS
  613.        Keywords
  614.        DOS  does  not  support existdir; MacDOS  does  not  support
  615.        errorlevel.
  616.  
  617.        Hidden files
  618.        Hidden files exist for MacDOS but not for DOS.
  619.  
  620.    Notes
  621.        Aliases
  622.        When  the  item  tested with exist or  existdir  includes  a
  623.        path,  MacDOS  resolves all the aliases of  folders  in  the
  624.        path  but  not the innermost one. Therefore, aliases  always
  625.        satisfy exist and never existdir, regardless of whether  the
  626.        target is a file or a folder.
  627.  
  628.        Incompatibility with FOR
  629.        IFs  are  not  allowed within standard FORs.  That  is,  you
  630.        cannot type:
  631.           for %var in (set) do if %var == ...
  632.        The  solution  is to use multi-line FORs (or  to  drop  FORs
  633.        altogether). Note that you can execute a FOR within an IF.
  634.  
  635.        Reserved words
  636.        The  words  not,  exist, and existdir are reserved  in  both
  637.        upper    and   lower   case.   Therefore,   commands    like
  638.        if  not  == %var%  are in most cases rejected with a  syntax
  639.        error. Here is an example in which IF might not do what  you
  640.        expect:
  641.           if not exist == %1 do_this
  642.        The  purpose  is probably to execute do_this  if  the  first
  643.        replaceable   parameter   contains   the   string   "exist".
  644.        Unfortunately, IF interprets the command line as  a  request
  645.        to  execute  "%1  do_this" if a file  named  "=="  does  not
  646.        exist.  Most likely, you do not have such a file. Therefore,
  647.        MacDOS  will  attempt to execute "%1 do_this". This  can  be
  648.        very  confusing, especially when you have ECHO disabled.  To
  649.        avoid   this  kind  of  problems,  you  have  the  following
  650.        choices:
  651.        •  Never use reserved words (preferred solution).
  652.        •  Double-quote  reserved  words and variables  which  could
  653.           contain reserved words:
  654.           if "%var%" == "not" do_this
  655.           if not "exist" == %1 do_this
  656.  
  657.        Spaces
  658.        Spaces  within a condition are ignored, unless  you  double-
  659.        quote  them. Also, strings containing spaces must be  double
  660.        quoted.
  661.  
  662.    Examples
  663.        Check the existence of a file:
  664.           if exist %1 echo file "%1" exists
  665.        Check the non-existence of a folder:
  666.           if not existdir %1 echo folder "%1" not there
  667.        Use  a  batch program to process all files in a folder,  but
  668.        only after checking that the folder exists:
  669.           if existdir %1 for %file in (%1) do processFile %1\%file
  670.        Check the control variable of a loop:
  671.           if %counter% == 7 goto EXIT_LOOP_LBL
  672.        Check an error condition:
  673.           if not %doserr% == 0 goto ERROR_LBL
  674.  
  675.    Frequently occurring errors
  676.        E13: Syntax: invalid arguments
  677.        Very often this error message is caused by a reference to  a
  678.        replaceable  parameter which was not defined.  For  example,
  679.        if  %1  == 3 do_this  fails if %1 is empty. It is so because
  680.        MacDOS,  after  replacing %1, only sees  if   ==  3  do_this
  681.        and  cannot  make  any sense of it. To avoid  this  problem,
  682.        append  a character to both sides of the condition (a  space
  683.        does  not work unless you use double quotes):  if %1x ==  3x
  684.        do_this  . Then MacDOS sees  if x == 3x do_this  and behaves
  685.        as expected.
  686.  
  687.  
  688. INCR
  689.        increments or extends values of global variables.
  690.  
  691.    Syntax
  692.  
  693.        incr [+ | -]var [by {number | string}]
  694.  
  695.        "incr var", equivalent to "incr +var by 1", increments by  1
  696.        numeric  values  and  appends  one  space  to  the  end   of
  697.        alphanumeric strings.
  698.  
  699.    Parameters
  700.        [+ | -]var
  701.        is  the  name of a global variable, possibly preceded  by  a
  702.        plus  or a minus sign. No space is allowed between the  sign
  703.        and  the variable name. INCR uses the sign to decide whether
  704.        to  perform string operations at the end or at the beginning
  705.        of var's value.
  706.  
  707.        number
  708.        is  a  signed  integer number. INCR uses number  differently
  709.        depending on whether var  contains a numeric value or not:
  710.        •  When  var contains a numeric value, INCR replaces it with
  711.           the value obtained after adding number.
  712.        •  When var contains an alphanumeric string which cannot  be
  713.           interpreted  as  a  number, INCR  extends  it  by  adding
  714.           number  spaces.  The characters are inserted  before  the
  715.           beginning  if the variable name is preceded by the  minus
  716.           sign,  otherwise they are appended after its  end.   When
  717.           number  is  negative, INCR actually shortens the  content
  718.           of  var  by removing characters from the end or from  the
  719.           beginning  (depending on the presence of the  minus  sign
  720.           before the variable name).
  721.  
  722.        string
  723.        is  an alphanumeric string which cannot be interpreted as  a
  724.        number.  INCR joins string to the string contained  in  var.
  725.        The string is prepended if the variable name is preceded  by
  726.        the minus sign, otherwise the string is appended.
  727.  
  728.    MacDOS vs DOS
  729.        DOS does not support INCR.
  730.  
  731.    Notes
  732.        Appending numeric characters
  733.        When  the  BY-string is numeric, INCR increments  a  numeric
  734.        variable by that amount or adds that number of spaces to  an
  735.        alphanumeric variable. If your purpose is to add  digits  to
  736.        a  variable (eg. appending '1' to the string "134"  so  that
  737.        it   becomes  "1341"),  you  can  achieve  this  result   by
  738.        extending  the  BY-string with an alphabetic  character  and
  739.        then   immediately  removing  it  from  the  variable   (ie.
  740.        INCR var BY 1x  followed by DECR var BY x).
  741.  
  742.    Examples
  743.           initial var   command             resulting var
  744.           "25"          incr var            "26"
  745.           "25"          incr -var           "26"
  746.           "-25"         incr var by 30      "5"
  747.           "25"          incr var by -3      "22"
  748.           "-7"          incr var by -30     "-37"
  749.           "abcde"       incr var            "abcde "
  750.           "abcde"       incr -var           " abcde"
  751.           "abcde"       incr var by 3       "abcde   "
  752.           "abcde"       incr var by -1      "abcd"
  753.           "abcde"       incr -var by -3     "de"
  754.           "ab de"       incr var by de      "ab dede"
  755.           "a cde"       incr -var by "a "   "a a cde"
  756.           "abcde"       incr +var by -7     var removed
  757.  
  758.    Frequently occurring errors
  759.        E63: Requested variable has not been defined
  760.        You  attempted to INCRement a variable that did  not  exist.
  761.        Remember  that  empty  variables are  automatically  removed
  762.        unless they are system variables.
  763.  
  764.    See Also
  765.        DECR, SSTR, TOUPPER
  766.  
  767.